<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <input type="text" id="input">
  <input type="submit" id="btn" value="提交">
  <script>
    //清除字符串的首尾空格，中间的空格不会清除
    const s='  abc '
    console.log(s);
    console.log(s.trimStart());
    console.log(s.trimEnd());
    console.log(s.trim());

    const input=document.getElementById('input')
    const btn=document.getElementById('btn')
    btn.onclick=function(){
      console.log(input.value);
      if(input.value.trim()!==''){
        console.log('可以提交');
      }else{
        console.log('不能提交');
      }
    }
  </script>
</body>
</html>